<template>
  <div class="dashboard-editor-container" v-wechat-title="'数据板'">
    <div class='ad'>
      <svg-icon icon-class="小喇叭" style="font-size: 28px;"/>
      <p class='content'>
        <span>重要通知：为了维护演示环境的正常使用，因此只开放了部分权限，可以在现有的权限下创建用户并分配已有的权限，如需体验完整环境，可以下载源码后按照文档教程进行搭建~</span>
      </p>
    </div>
    <!-- 顶部内容 -->
<!--    <el-row class="panel-group" :gutter="40" >-->
<!--&lt;!&ndash;      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col" style="margin-left: 200px">&ndash;&gt;-->
<!--&lt;!&ndash;        <div class="card-panel" @click="$router.push({path:'account/userList'})">&ndash;&gt;-->
<!--&lt;!&ndash;          <div class="card-panel-icon-wrapper icon-people">&ndash;&gt;-->
<!--&lt;!&ndash;            <svg-icon icon-class="peoples" class-name="card-panel-icon"/>&ndash;&gt;-->
<!--&lt;!&ndash;          </div>&ndash;&gt;-->
<!--&lt;!&ndash;          <div class="card-panel-description">&ndash;&gt;-->
<!--&lt;!&ndash;            <div class="card-panel-text">用户数:</div>&ndash;&gt;-->
<!--&lt;!&ndash;            <span class="card-panel-num">{{this.userTotal}}</span>&ndash;&gt;-->
<!--&lt;!&ndash;          </div>&ndash;&gt;-->
<!--&lt;!&ndash;        </div>&ndash;&gt;-->
<!--&lt;!&ndash;      </el-col>&ndash;&gt;-->
<!--      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col" >-->
<!--        <div class="card-panel" @click="$router.push({path:'blog/blog'})">-->
<!--          <div class="card-panel-icon-wrapper icon-shoppingCard">-->
<!--            <svg-icon icon-class="form" class-name="card-panel-icon"/>-->
<!--          </div>-->
<!--          <div class="card-panel-description">-->
<!--            <div class="card-panel-text">文章总点击数:</div>-->
<!--            <span class="card-panel-num">{{this.blogTotal}}</span>-->
<!--          </div>-->
<!--        </div>-->
<!--      </el-col>-->
<!--      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">-->
<!--        <div class="card-panel" @click="$router.push({path:'blog/blog'})">-->
<!--          <div class="card-panel-icon-wrapper icon-shoppingCard">-->
<!--            <svg-icon icon-class="form" class-name="card-panel-icon"/>-->
<!--          </div>-->
<!--          <div class="card-panel-description">-->
<!--            <div class="card-panel-text">文章总数:</div>-->
<!--            <span class="card-panel-num">{{this.blogTotal}}</span>-->
<!--          </div>-->
<!--        </div>-->
<!--      </el-col>-->


<!--    </el-row>-->

    <!--文章贡献度-->
    <el-row >
      <el-col>
        <CalendarChart></CalendarChart>
      </el-col>
    </el-row>


    <el-row :gutter="50" >
      <!-- 分类饼图 -->
      <el-col :xs="24" :sm="24" :lg="8" :offset="4">
        <div class="chart-wrapper">
          <pie-chart v-if="isShowCategoryPie" :value="categoryPieValue" :tag-name="categoryPieTagName" :title="categoryTitle" @clickPie="clickCategoryPie"></pie-chart>
        </div>
      </el-col>
      <!-- 标签饼图-->
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart v-if="isShowTagPie" :value="labelPieValue" :tag-name="labelPieTagName" :title="labelTitle" @clickPie="clickLabelPie"></pie-chart>
        </div>
      </el-col>
    </el-row>
    <!-- PV/UV -->
    <!--访问量统计-->
    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <el-col>
        <line-chart style="max-width: 3000px;height: 500px"> </line-chart>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import CalendarChart from "@/components/CalendarChart";
import PieChart from "@/components/PieChart";
import LineChart from "@/components/LineChart"
import { init,getCategoryPieData,getLabelPieDate } from "@/api/index"
import * as echarts from 'echarts';
export default {
  name: "index",
  components:{CalendarChart,PieChart,LineChart},
  data() {
    return {
      userTotal: 0,
      commentTotal: 0,
      blogTotal: 0,
      isShowCategoryPie: false,
      isShowTagPie: false,
      categoryTitle: '分类饼图',
      categoryPieValue: [],
      categoryPieTagName: [],
      labelTitle: '标签饼图',
      labelPieValue: [],
      labelPieTagName: [],
    }
  },
  created() {
    this.init();
    this.getCategoryPieData();
    this.getLabelPieDate();
  },
  methods:{
    init(){
      // init().then( res => {
      //   this.userTotal = res.data.data.initData.userCount
      //   this.commentTotal = res.data.data.initData.commentCount
      //   this.blogTotal = res.data.data.initData.blogCount
      // })
    },
    getCategoryPieData(){
      getCategoryPieData().then( res => {
        this.isShowCategoryPie = true
        this.categoryPieTagName = res.data.name
        this.categoryPieValue = res.data.value
      })
    },
    getLabelPieDate(){
      getLabelPieDate().then( res => {
        this.isShowTagPie = true
        this.labelPieTagName = res.data.name
        this.labelPieValue = res.data.value
      })
    },
    clickCategoryPie(index) {
      let category = this.categoryPieTagName[index]
      this.$router.push({
        path: "/blog/blog",
        query: { category: category.name }
      });
    },
    clickLabelPie(index){
      let label = this.labelPieTagName[index]
      this.$router.push({
        path: "/blog/blog",
        query: { label: label.name }
      });
    },
  },
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@keyframes marquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-80%);
  }
}

.content{
  span{
    animation: marquee 30s linear infinite;
  }
}

.ad {
  width: 1000px;
  height: 60px;
  background-color: #fff;
  border-radius: 10px;
  box-sizing: border-box;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 16px;
  color: #353535;
  box-shadow: 2px 1px 8px 1px rgb(228, 232, 235);

  i {
    color: #ff6146;
    font-size: 20px;
    margin-right: 10px;
  }

  .content{
    flex: 1;
    overflow: hidden;
    margin-left: 15px;
    span {
      display: block;
      width: auto;
      white-space: nowrap;
    }
  }
}

.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }
      .icon-people {
        background: #40c9c6;
      }
      .icon-message {
        background: #36a3f7;
      }
      .icon-money {
        background: #f4516c;
      }
      .icon-shoppingCard {
        background: #34bfa3;
      }
    }
    .icon-people {
      color: #40c9c6;
    }
    .icon-message {
      color: #36a3f7;
    }
    .icon-money {
      color: #f4516c;
    }
    .icon-shoppingCard {
      color: #34bfa3;
    }
    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }
    .card-panel-icon {
      float: left;
      font-size: 48px;
    }
    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px 70px 0 0;
      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }
      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}
</style>
